package cn.hbads.support.http.client.model;

import lombok.Builder;

import java.net.http.HttpClient;
import java.time.Duration;

/**
 * <b>发送请求客户端配置模型</b>
 *
 * @param version   http协议版本
 * @param timeout   超时时间
 * @param proxyHost 代理主机
 * @param proxyPort 代理端口
 * @param redirect  重定向策略
 * @author yvvb
 * @date 2025/5/4
 */
@Builder
public record HttpClientModel(HttpClient.Version version, Duration timeout, String proxyHost, int proxyPort,
                              HttpClient.Redirect redirect) {
    public static final Duration DEFAULT_TIME_OUT = Duration.ofSeconds(20);

    public static HttpClientModel defaultInstance() {
        return HttpClientModel.builder()
                .version(HttpClient.Version.HTTP_1_1)
                .redirect(HttpClient.Redirect.NORMAL)
                .timeout(DEFAULT_TIME_OUT)
                .build();
    }

}
